function getVal <T>(val:T): T{
    return val;
}
getVal<string>('123')
getVal<number>(123)

interface Par<T>{
    pageSize:T,
    pageNum:T
}
let dat:Par<number> = {
    pageSize:123,
    pageNum:321
}
let dat1:Par<string> = {
    pageSize:"123",
    pageNum:"321"
}

//泛型约束
interface getLength{
    length:number
}
function getLength1<T extends getLength>(val: T):number{
    return val.length
}

console.log(getLength1('123'))
console.log(getLength1([1,2,3]))